package com.jueban.Vo;

import com.jueban.model.user.User;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.Page;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class UsersVo extends ResultVo {

    List<UserVo> users = new ArrayList<UserVo>();
    int offset;
    int pageNumber;
    int pageSize;

    /*
    public UsersVo(Page<User> userPage) {
        setProperties(userPage);
    }*/

    public UsersVo() {

    }

    public void setProperties(Page<User> userPage) {
        pageSize = userPage.getSize();
        //pageNumber = (int) (userPage.getTotalElements() / pageSize);
        pageNumber = userPage.getTotalPages();
        offset = userPage.getNumber();
        for (User user : userPage) {
            UserVo userVo = new UserVo(user);
            users.add(userVo);
        }
    }

}
